package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingBloodOxygen;
import com.ruoyi.ring.service.IRingBloodOxygenService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 血氧Controller
 * 
 * @author liuwp
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/ring/ring_blood_oxygen")
public class RingBloodOxygenController extends BaseController
{
    @Resource
    private IRingBloodOxygenService ringBloodOxygenService;

    /**
     * 查询血氧列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingBloodOxygen ringBloodOxygen)
    {
        startPage();
        List<RingBloodOxygen> list = ringBloodOxygenService.selectRingBloodOxygenList(ringBloodOxygen);
        return getDataTable(list);
    }

    /**
     * 导出血氧列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen:export')")
    @Log(title = "血氧", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingBloodOxygen ringBloodOxygen)
    {
        List<RingBloodOxygen> list = ringBloodOxygenService.selectRingBloodOxygenList(ringBloodOxygen);
        ExcelUtil<RingBloodOxygen> util = new ExcelUtil<RingBloodOxygen>(RingBloodOxygen.class);
        util.exportExcel(response, list, "血氧数据");
    }

    /**
     * 获取血氧详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringBloodOxygenService.selectRingBloodOxygenById(id));
    }

    /**
     * 新增血氧
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen:add')")
    @Log(title = "血氧", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingBloodOxygen ringBloodOxygen)
    {
        return toAjax(ringBloodOxygenService.insertRingBloodOxygen(ringBloodOxygen));
    }

    /**
     * 修改血氧
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen:edit')")
    @Log(title = "血氧", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingBloodOxygen ringBloodOxygen)
    {
        return toAjax(ringBloodOxygenService.updateRingBloodOxygen(ringBloodOxygen));
    }

    /**
     * 删除血氧
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_blood_oxygen:remove')")
    @Log(title = "血氧", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringBloodOxygenService.deleteRingBloodOxygenByIds(ids));
    }

}
